package com.diaohaiwen.framework.file.obj;

import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author 刁海文
 * @since 2023/12/16 22:42
 */
@Data
public class FileInfo {

    /**
     * 令牌通过
     */
    private String bucket;
    /**
     * 目录
     */
    private String folder;

    private String contentType;
    /**
     * 原始文件名称
     */
    private String filename;
    /**
     * /**
     * 大小
     */
    private long length;

    public static String folder() {
        return DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd");
    }

    public String path() {
        return folder + "/" + filename;
    }

    public static FileInfo build(String bucket, String contentType, String folder, String filename, long length) {
        FileInfo info = new FileInfo();
        info.bucket = bucket;
        info.contentType = contentType;
        info.folder = folder;
        info.filename = filename;
        info.length = length;
        return info;
    }
}
